home *** CD-ROM | disk | FTP | other *** search
/ Loadstar 128 #35 / q35.d81 / t.ps to font < prev    next >
Encoding:
Text File  |  1992-01-01  |  15.2 KB  |  376 lines

  1.  
  2.  
  3.                 1 2 8   P R I N T   S H O P   T O   F O N T
  4.  
  5.                       Program and Text by Bob Markland
  6.  
  7.  
  8.     The primary reason for selecting a C-128 over a C-64, aside from the
  9. extra memory, is the 80-column mode. And here at LOADSTAR 128 nearly every
  10. program is in the 80-column mode.
  11.  
  12.     As you no doubt know, the C-128 uses the text-oriented 8563 Video
  13. Display Controller chip (VDC) to display the 80-column screen. Besides
  14. allowing longer screen lines, its advantages include vivid colors,
  15. additional attributes, and the ability to display two fonts (512 different
  16. characters) simultaneously. And, unlike the VIC chip which stores
  17. characters in ROM, the VDC chip's character sets are addressable in place.
  18.  
  19.     But, alas, there is a down side -- the VDC chip is text-oriented. There
  20. is a limited bit-map mode, but the 640 x 400 pixels eat up nearly all of
  21. the 8563's available memory. Ordinarily only the background and one
  22. foreground color is available --  you can cut the bit-map by 1/4 and regain
  23. color control -- but in any event the character sets are gone.
  24.  
  25.     An experienced (or masochistic) M/L programmer can overcome these
  26. problems, but few have even attempted it. And no adequate solution is
  27. available from BASIC. So, many 80-column programs lack the visual
  28. enhancements common to C-64 programs.
  29.  
  30.     How about a compromise? What if you could easily display a smaller
  31. graphic anywhere on the screen?
  32.  
  33.     Print Shop Icons are an ideal source for small graphics. Existing
  34. images are plentiful or you can use The Print Shop Companion to draw just
  35. the graphic you want. LOADSTAR's COMPLEAT PRINT SHOP disks contain over
  36. 2600 Print Shop icons. You're sure to find an icon in this collection to
  37. fit your needs.
  38.  
  39.     Armed with a good idea for a program and an icon library you're almost
  40. ready to begin, except for two major impediments. Print Shop 3-block icons
  41. are stored in a format totally unlike any Commodore screen or font storage.
  42. And, on the 80-column screen, if icons were displayed at their normal 11
  43. byte width, they would be "squashed" horizontally. So a utility is needed
  44. to alter the format and double the width, and 128 PRINT SHOP TO FONT does
  45. just that.
  46.  
  47.  
  48.  USING PRINT SHOP TO FONT
  49.  ------------------------
  50.  
  51.     128 PS TO FONT is a freestanding utility. You can write a program that
  52. uses only the utility and icons. However, it is also compatible with
  53. CONTROL80 and 128 RLE for more complex applications.
  54.  
  55.     First you must decide how you are going to make use of the PS icons. If
  56. your program will use only a few icons, you can store them on disk
  57. individually and BLOAD them as needed.
  58.  
  59.     When numerous icons are required you should bundle them into a single
  60. file. There are several ways to accomplish this, but here is the method I
  61. used for the demo:
  62.  
  63.   1) With no program in memory, enter the built-in MONITOR and fill an area
  64. of memory with a known value, let's say, BB.
  65.  
  66.          F 02000 04000 BB
  67.  
  68.      then exit the monitor.
  69.  
  70.   2) BLOAD all of your icons into successive areas of memory, 3 pages apart
  71. (768 bytes), from direct mode, as follows:
  72.  
  73.          BLOAD"Icon 1",B0,P8192
  74.          BLOAD"Icon 2",B0,P8960
  75.                  etc.
  76.  
  77.     There are two reasons for spacing the icons on page boundaries. First,
  78. a PS icon is 11 characters wide and 6-1/2 characters high. 128 PS TO FONT
  79. uses the 44 bytes beyond each icon as a work area to account for the stray
  80. 1/2 character. Second, it is easier to keep track of the indexing for
  81. multiple icons.
  82.  
  83.     You could write a 3-line Q&D program to read the icon names from DATA
  84. statements, increment the load address with a variable, and complete the
  85. above process in one operation. But, unless you plan to make several icon
  86. files, it may not be worth the bother.
  87.  
  88.   3) When all of your icons are in memory, enter the MONITOR again, and
  89. scan memory with the "M" command to find the ending address of the last
  90. icon plus one (+1). Note the address and exit the monitor.
  91.  
  92.   4) BSAVE the icons as a single file using the following syntax, where
  93. "start" is the beginning address of the first icon and "end" is the address
  94. of the end of the last icon:
  95.  
  96.  BSAVE"FILENAME,B0,Pstart TO Pend+1
  97.  
  98.  Or, if you're comfortable with the monitor, you could save the icons as a
  99. single file inside the monitor, using hex numbers and the S (save)
  100. command.
  101.  
  102.   5) If the icon file is relatively short you may wish to end the process
  103. at this point. Otherwise, use 128 RLE (Run Length Encoding) Packer/Unpacker
  104. to "PACK A FILE", thus creating a file which takes up less disk space and
  105. loads more quickly. Then include 128 RLE in your program to unpack the
  106. file.
  107.  
  108.     You are now ready to begin your program. There are six versions of 128
  109. PS TO FONT on disk and their file names indicate the necessary load
  110. address:
  111.  
  112.         128 PS-FONT 0C00
  113.         128 PS-FONT 1300
  114.         128 PS-FONT 1C00
  115.         128 PS-FONT 2400
  116.         128 PS-FONT 3500
  117.         128 PS-FONT 3800
  118.  
  119.     If you absolutely need a version at a location not found above, you can
  120. use Jeff Jones' ML MOVER from LS 64 #156 to create versions almost anywhere
  121. you want.
  122.  
  123.     Use BLOAD to load 128 PS TO FONT into bank 0, where dv is the number of
  124. the active device:
  125.  
  126.       BLOAD"128 PS-FONT xxxx",B0,U(dv)
  127.  
  128.     The choice of which version to use depends upon what else you have
  129. going on. If 128 PS TO FONT is the only utility you will be using, $0C00 or
  130. $1300 are perhaps the best choices. You will notice the accompanying demo
  131. uses both CONTROL80 and 128-RLE so the $1C00 version is the one to use. The
  132. remaining versions are intended to nestle among the various incarnations of
  133. CONTROL80, custom fonts, etc. If you choose to move the start of BASIC to
  134. $4000, any of the higher versions may be used, with or without other
  135. utilities.
  136.  
  137.  FENDER'S NOTE: When I use CONTROL80, I invariably move the start of BASIC
  138. up to $4000 with the GRAPHIC1,1:GRAPHIC0:GRAPHIC5 sequence. I've never
  139. written a 128 mode BASIC program so large that I needed BASIC to start at
  140. the normal $1300, or even $1C00. So why not move BASIC up to $4000 and use
  141. that open area from the top of CONTROL80 to $4000 for buffers, ML routines,
  142. etc.?
  143.  
  144.     128 PS TO FONT supports two different types of icon displays -- full-
  145. size and cropped. Full-size icons require 154 characters (22 x 7). As a
  146. result, only two different icons may be imbedded in the character sets. One
  147. in the upper portion of font 0 and the other in the upper portion of font
  148. 1.
  149.  
  150.     This not only limits the number of possibilities, but the 22 x 7 size
  151. doesn't space well on a 80 x 25 screen. Unless there is a critical need to
  152. display the entire icon, cropping is preferable.
  153.  
  154.     128 PS TO FONT can automatically crop an icon for you. The utility
  155. trims 2 rows of pixels from the top and bottom of the image and 4 pixels
  156. from both the left and right sides. The resulting image is 20 x 6
  157. characters in size. You may wish to take this into consideration when you
  158. select your icons, and use Print Shop Companion to edit them beforehand.
  159.  
  160.     Sixteen cropped icons fit nicely on the screen and you can store three
  161. different icons simultaneously, still leaving 128 character definitions for
  162. text.
  163.  
  164.     Numerous arrangements are possible, depending upon the needs of your
  165. program. Some of the possibilities include:
  166.  
  167.   1) Store one icon in the upper half of font 0 and another in the upper
  168. half of font 1. This leaves both uppercase and lowercase text intact.
  169.  
  170.   2) Reverse the above process, leaving both reversed character sets
  171. available.
  172.  
  173.   3) Store two icons in one font or the other. You then have one entire
  174. character set for text/graphics characters.
  175.  
  176.   4) Store two icons in one or the other font and one in half of the
  177. remaining font. 128 text characters remain available in either normal or
  178. reverse.
  179.  
  180.   It is theoretically possible to store four icons at one time. However,
  181. doing so will corrupt any text characters on the screen and prevent further
  182. use of text until at least one font is restored with CONTROL80's FCOPY.
  183.  
  184.     While it is not necessary to include a custom font, if you plan to
  185. write a program for LOADSTAR it is not likely to be accepted without one.
  186. Include CONTROL80 in your program and FCOPY a custom font into place before
  187. using 128 PS TO FONT.
  188.  
  189.     You should also be aware that alterations to the fonts can cause a
  190. BASIC listing to look weird at best, unintelligible at worst. The trick is
  191. to enter FINIT in the immediate mode to restore normal fonts. You may even
  192. want to use a TRAP routine to automatically do a FINIT when you press STOP
  193. to edit your program.
  194.  
  195.     How and where you load the icon images depends upon what other
  196. utilities you may be using. If you are using single icons, use the same 3-
  197. block area of Bank 0 and load to it repeatedly. When CONTROL80 is in use
  198. memory becomes a little more scarce. Personally, I prefer to use Bank 1 for
  199. storage. Bank 1 is the bank BASIC uses for variable storage. Numeric
  200. variables and static strings are stored from $0400 upward and dynamic
  201. strings are stored from $FF00 downward. Unless your program uses a huge
  202. number of variables or you have somehow induced garbage collection problems
  203. (by creating a bunch of concatenated strings), a large section of memory in
  204. the middle of Bank 1 remains free.
  205.  
  206.     Once you have 128 PS TO FONT and at least one icon in place you are
  207. ready to display it. Everything is handled with one simple SYS command:
  208.  
  209.         SYSADDR:B,IA,F,P,C
  210.  
  211.     Because of the way BASIC 7.0 handles the SYS command you MUST include
  212. the colon (:) before the first parameter.
  213.  
  214.   SYSADDR - Is the starting ADDRess of the version of 128 PS TO FONT you
  215. are using.
  216.  
  217.   B - Is the Bank where your icon images reside (0 or 1).
  218.  
  219.   IA - This is the address of the icon you wish to transfer to a font. Note
  220. that this can be a variable or formula. When you have a series of icons in
  221. a single file, stored as explained above, you can address them with:
  222.  
  223.      Icon Address+768*Location Number
  224.  
  225.   F - Selects the Font into which you wish to imbed the icon (0 or 1):
  226.  
  227.      Font 0 - Uppercase/Graphics
  228.      Font 1 - Lowercase
  229.  
  230.   P - Determines the Position within the selected font (0 or 1):
  231.  
  232.      0 - Selects lower half - Normal
  233.      1 - Selects upper half - Reverse
  234.  
  235.     Note: If you select Normal for the cropped option, 1 is the only
  236. setting possible for Position, and the utility will force this condition if
  237. necessary.
  238.  
  239.  C - This option tells the utility to transfer a normal or Cropped image:
  240.  
  241.      0 - Cropped
  242.      1 - Normal
  243.  
  244.     Compiler and M/L uses are also supported. Because compilers choke on
  245. the non-standard method used to get the parameters use this instead:
  246.  
  247.      POKEload address+551,BANK
  248.      POKE176,low byte Icon Address
  249.      POKE177,high byte Icon Address
  250.      POKEload address+552,FONT
  251.      POKEload address+553,POSITION
  252.      POKEload address+554,CROP
  253.      SYSADDR+3
  254.  
  255.     From a M/L program:
  256.          lda bank
  257.          sta load'addr+551
  258.          lda <icon'address
  259.          sta $b0
  260.          lda >icon'address
  261.          sta $b1
  262.          lda font
  263.          sta load'addr+552
  264.          lda position
  265.          sta load'addr+553
  266.          lda crop
  267.          sta load'addr+554
  268.          jsr sys'addr+3
  269.  
  270.  
  271.     You now have an icon in one of your fonts, but it is not yet displayed
  272. on the screen. To do this you must define a string.
  273.  
  274.     Now is probably a good time to print a copy of this text and run the
  275. PRINT SHOP TO FONT DEMO. After viewing the demo you can break out with
  276. STOP/RESTORE and more easily follow the logic.
  277.  
  278.  
  279.  DISPLAYING ICONS
  280.  ----------------
  281.  
  282.     There are several ways to define your print string, but I prefer to
  283. READ from DATA statements and concatenate one long string. All the
  284. important sections of the demo are REMmed so you can easily incorporate
  285. them into your own program.
  286.  
  287.     CR$ is for the display of cropped icons. It consists of the first 120
  288. CHR$ values as a font is laid out. The string is the same for both normal
  289. and reversed. The difference is accounted for when you print CR$.
  290.  
  291.   PRINTCHR$(146)CR$ - for an icon in position 0 (reverse off)
  292.  
  293.   PRINTCHR$(18)CR$ - for an icon in position 1 (reverse on)
  294.  
  295.     FL$ is for displaying FulL-size icons. It consists of the last 26
  296. characters from the first half of the font, a CHR$(18), and the 128
  297. characters from the second half of the font.
  298.  
  299.     You must also include CHR$(142) and CHR$(14) in the PRINT command
  300. depending upon whether the icon is in font 0 or 1. For example:
  301.  
  302.     PRINTCHR$(142)CHR$(18)CR$ - for an icon in font 0, position 1.
  303.  
  304.     This may sound a bit confusing at first, but after you LIST and examine
  305. the demo you will find it is quite easy.
  306.  
  307.     Another key element in displaying icons with a minimum of effort is the
  308. WINDOW command. You will notice in the above text, there is no provision
  309. for carriage returns (CHR$(13)) following each series of 20 or 22
  310. characters. There is a very good reason for this.
  311.  
  312.     Use the following syntax to define a window and display an icon in it:
  313.  
  314.      WINDOW TC,TR,TC+19,TR+5,[1]:
  315.      PRINTCHR$(27)"M":COLOR5,CO:
  316.      PRINTCHR$(142)CHR$(18)CR$
  317.  
  318.   TC = Top left Column
  319.   TR = Top left Row
  320.   [1] - Is optional and clears the window before printing
  321.   CHR$(27)"M" - prevents the window from scrolling
  322.   CO - Determines the color of the icon to be displayed
  323.  
  324.     To display full-size icons, simply use TC+21, TR+6 and FL$ in the above
  325. example.
  326.  
  327.     It is not necessary to use a window if you prefer not to. Instead, you
  328. can imbed CHR$(13)s in the appropriate places within the string.
  329.  
  330.     You can also use an array:
  331.  
  332.      CR$(1)="@ABCDEFGHIJKLMNOPQRS"
  333.      CR$(2)=  second line
  334.      CR$(3)=  third line
  335.                   etc.
  336.  
  337.     By calculating which characters make up the image you can also print
  338. color change commands and selected characters to produce a multi-color icon
  339. image.
  340.  
  341.     If you elect to use CONTROL80 in your program, in addition to custom
  342. fonts, you can use POST and an array to display an entire icon. Or you can
  343. use POST, BLOCK or FILL to achieve multi-color effects and flashing
  344. characters.
  345.  
  346.     The demo also illustrates how you can quickly change an icon image
  347. already on the screen. This is accomplished by simply transferring a
  348. different icon to the same area of the appropriate font.
  349.  
  350.     To create even larger images you can use Print Shop Companion to draw
  351. three icons which are a part of a larger graphic. Then link or stack the
  352. icons on screen to form a single large mural. On the other hand, in a game
  353. or puzzle, you could selectively display only a portion of an icon. For
  354. that matter you could draw a custom icon which has a different image in
  355. each quadrant. Then by displaying only a quarter of each icon with a PRINT
  356. statement you could have 12 different smaller images on the screen at
  357. once.
  358.  
  359.     With a little imagination and experimentation, there should be no limit
  360. to the effects you can create. You will surely think of numerous
  361. possibilities I haven't even considered.
  362.  
  363.  FT'S POSTMUMBLE: Is 128 PS TO FONT fast enough for animation? I remember
  364. making a demo for the C-64 version of PS TO FONT years ago and it
  365. "simulated" animation of Medusa, the snake-haired lady. I allowed the user
  366. to set the speed and found that the animation looked best at a less than
  367. maximum speed. So let us know, if you use this utility to attempt some
  368. "small-screen" animation, how it goes. I see 128 PS TO FONT as a tool
  369. begging for someone to use in a creative way. If you tackle animation,
  370. you'll still have all the hard work of making multiple copies of some PS
  371. icons, but at least the displaying will be painless, thanks to Bob
  372. Markland.
  373.  
  374.                     \\\\\ R - Run   RETURN - Menu \\\\\
  375.  
  376.